home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor2 / fft7.doc < prev    next >
Text File  |  1995-03-31  |  2KB  |  54 lines

  1. (Comp.sources.hp48) 
  2. Item: 138 by kcooke@milton.u.washington.edu [Ken Cooke] 
  3. Subj: Machine Code FFT 
  4. Date: 12 Jul 1992 
  5.  
  6. Here is some FFT code that I wrote several months ago but never got around 
  7. to posting.  I tried to make it fast enough to be useful.  The code is based 
  8. on the standard DIT radix-2 FFT, so the input length must be a power of 2. 
  9. All intermediate math is done in 15-digit precision, which gives very accurate 
  10. results. (a 1024-point FFT matches MATLAB to 12 digits) 
  11.  
  12. I used the following definition of the FFT: 
  13.                 N-1 
  14.          X[k] = Sum( x[n] * exp(-j*2pi*k*n/N) ) 
  15.                 n=0 
  16.                       N-1 
  17.          x[n] = 1/N Sum( X[k] * exp(j*2pi*k*n/N) ) 
  18.                       k=0 
  19.  
  20. Quick description of the programs in this UUENCODED directory: 
  21.  
  22. FFT: machine code FFT.  Input is a vector (either real or complex). 
  23. Size must be a power of two.  Output is a complex vector.  Includes 
  24. error checking.  I believe this is as fast as the HP48 can be at a complex 
  25. FFT.  Random 128-pt complex FFT: 7.5 seconds.  About 8 times faster than 
  26. system RPL, and 1.5 times faster than the FFT in the HP71 mathpack after 
  27. compensating for clock speed differences.  (I did not look at the mathpack 
  28. code) 
  29.  
  30. IFFT: inverse FFT.  Could have been combined with the FFT program, but I 
  31. hate using an additional argument to tell it which one to do. 
  32.  
  33. ABSV: machine code absolute value.  Input can be a vector or matrix. 
  34. Output is a vector or matrix containing the absolute values of the complex 
  35. elements.  About 5 times faster than RPL. 
  36.  
  37. ANGLE: same as ABSV, but returns the angle (i.e. phase) according to the 
  38. current angle mode.  This is only 2 or 3 times as fast as RPL, because 
  39. the mcode arctan is such a bottleneck. 
  40.  
  41. SPEC(trum): User code quickie that does FFT, ABSV, and then plots using the 
  42. built-in barplot function.  Note that plot is from 0..2pi as returned by FFT. 
  43.  
  44. DISCLAIMER 
  45. While I believe these programs to be accurate and bug-free, I 
  46. will assume no responsibility for any Memory Lost, hardware damage, or 
  47. poor test scores that result from use of this code. 
  48.  
  49. Please let me know if you find a bug or have suggestions. 
  50.  
  51. Ken Cooke 
  52. N7VFE 
  53. kcooke@u.washington.edu 
  54.